﻿#include<iostream>
using namespace std;
#include<algorithm>

#include"AVL.h"

void test01()
{
	//AVL<int, int> root;
	//root.insert(90);
	//root.insert(30);
	//root.insert(60);
	//root.insert(40);
	//root.insert(35);
	//root.insert(34);
	//root.insert(32);
	//root.InOrder();
	//cout << root.High() << endl;
	//AVL<int, int>::Node* cur = root.find(60);

	int a[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15 };
	//int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
	AVL<int, int> r;
	for (auto e : a)
	{
		r.insert(e);
	}
	cout << r.IsBalance() << endl;
	r.InOrder();
	cout << r.High() << endl;
}
void test02()
{
	srand(time(0));
	AVL<int, int> root;
	const int n = 10000000;
	int* a = new int[n];

	int b1 = clock();

	//for(auto e : a)	//err
	for (int i = 0; i < n; ++i)
	{
		int tmp = rand() + i;
		a[i] = tmp;
		root.insert(tmp);
	}
	int e1 = clock();
	cout << "insert:" << e1 - b1 << endl;
	cout << "high:" << root.High() << endl;
	cout << root.Size() << endl;
	cout << root.IsBalance() << endl;

	int b2 = clock();
	sort(a, a + n);
	int e2 = clock();
	cout << "sort: " << e2 - b2 << endl;
}
void test03()
{
	AVL<int, int> r1;
	int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
	for (auto e : a)
	{
		r1.insert(e);
	}
	AVL<int, int> r2(r1);
	r2.InOrder();
	cout << r2.IsBalance() << endl;
	AVL<int, int> r3;
	r3 = r1;
}
int main()
{
	test03();
	return 0;
}